#!/usr/bin/python2.5
# Copyright 2009 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Controller for handling queries."""

from google.appengine.ext import webapp
import wsgiref.handlers


class IndexController(webapp.RequestHandler):
  def get(self):
    self.response.out.write('<a href="/static/floodmap/map.html">Queensland 2011 Flood Map</a><br/>')
    self.response.out.write('<a href="/static/mobile.html">Queensland 2011 Flood Road Closures (Mobile Version)</a><br/>')
    self.response.out.write('<a href="/fires/FireMap.html ">Bushfire Map '
                            'using Google Maps (flash required)</a><br/>')
    self.response.out.write('<a href="/static/firemap.html ">Mobile Bushfire '
                            'Map using Google Maps (javascript)</a><br/>')
    self.response.out.write('<a href="http://www.gmodules.com/ig/creator?'
                            'synd=open&url=http://mapvisage.appspot.com/'
                            'fires/firesgadget.xml">BushFire Map Gadget '
                            'for iGoogle</a><br/>')
    self.response.out.write('<a href="/query/fire?agency=viccfa&geocode=1'
                            '">Victorian CFA RSS feed (cached)</a><br/>')
    self.response.out.write('<a href="/query/fire?agency=nswrfs">NSW RFS '
                            'RSS feed (cached)</a><br/>')
    self.response.out.write('<a href="/query/fire?agency=tastfs">Tas TFS '
                            'RSS feed (cached)</a><br/>')
    self.response.out.write('<a href="/query/fire?agency=sacfs">SA CFS RSS '
                            'feed (generated, cached)</a><br/>')
    self.response.out.write('<a href="/query/fire?agency=merged">Merged RSS '
                            'feed (generated, cached)</a><br/>')


class ReliefController(webapp.RequestHandler):
  def get(self):
    self.response.out.write('<a href="http://www.redcross.org.au/vic/'
                            'services_emergencyservices_victorian-bushfires'
                            '-appeal-2009.htm">Australian Red Cross Victorian'
                            ' Bushfires 2009</a><br/>')


def main():
  app = webapp.WSGIApplication([('/', IndexController),
                                ('/relief', ReliefController)], debug=True)
  wsgiref.handlers.CGIHandler().run(app)

if __name__ == '__main__':
  main()
